package regist;
import javax.sql.DataSource;

import cn.hutool.db.ds.DSFactory;
import cn.hutool.setting.Setting;

public class PropertyConfig {
	
	private static Setting allConfig = new Setting("application.properties");
	private static Setting config = null;
	private static DataSource ds = null;
	
	static {
		String active = allConfig.getStr("active");
		config = allConfig.getSetting(active);
		ds = DSFactory.get(active); //配置数据库
	}
	
	public static void init() {
		String active = allConfig.getStr("active");
		config = allConfig.getSetting(active);
		ds = DSFactory.get(active); //配置数据库
	}
	
	public static DataSource getDs() {
		if(ds == null) {
			String active = allConfig.getStr("active");
			ds = DSFactory.get(active); //配置数据库
		}
		return ds;
	}
	public static String getStr(String key) {
		return config.getStr(key);
	}
	
}
